<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSuggest extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('suggest')) {
            Schema::create('suggest', function (Blueprint $table) {
                $table->id();
                $table->string('title')->default('')->comment('标题');
                $table->string('source')->default('')->comment('来源');
                $table->string('level')->default('')->comment('级别');
                $table->unsignedInteger('project_id')->default(0)->comment('所属项目ID');
                $table->unsignedInteger('task_id')->default(0)->comment('所属任务ID');
                $table->unsignedInteger('charge_user_id')->default(0)->comment('问题负责人ID');
                $table->unsignedInteger('create_user_id')->default(0)->comment('问题提出人ID|创建人ID');
                $table->text('description')->nullable()->comment('问题描述');
                $table->string('status')->default('')->comment('状态');
                $table->unsignedTinyInteger('mark')->default(1)->comment('是否删除标记');
                $table->integer('create_time')->nullable();
                $table->integer('update_time')->nullable();
            });
        }

        if (!Schema::hasTable('suggest_resolve')) {
            Schema::create('suggest_resolve', function (Blueprint $table) {
                $table->id();
                $table->unsignedInteger('suggest_id')->default(0)->comment('所属意见ID');
                $table->string('category')->default('')->comment('分类');
                $table->string('resolve_date')->default('')->comment('问题解决时间');
                $table->text('reason')->nullable()->comment('原因');
                $table->text('scheme')->nullable()->comment('方案');
                $table->text('description')->nullable()->comment('备注');
                $table->integer('create_time')->nullable();
                $table->integer('update_time')->nullable();
            });
        }

        if (!Schema::hasTable('suggest_resolve_user')) {
            Schema::create('suggest_resolve_user', function (Blueprint $table) {
                $table->id();
                $table->unsignedInteger('suggest_resolve_id')->default(0)->comment('问题解决ID');
                $table->unsignedInteger('user_id')->default(0)->comment('解决人ID');
                $table->integer('create_time')->nullable();
                $table->integer('update_time')->nullable();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('suggest');
    }
}
